package sketch.seg.cd;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;

public class CDParameterList {

	public static class CDParameter {

		private List<CDParameterNode> parameters;

		public CDParameter() {
			parameters = new ArrayList<CDParameterNode>();
		}

		public boolean appendNode(CDParameterNode pn) {
			return parameters.add(pn);
		}

		public List<CDParameterNode> getNodes() {
			return Collections.unmodifiableList(parameters);
//			return parameters;
		}

		public void print() {
			List<CDParameterNode> list = getNodes();
			for (Iterator<CDParameterNode> it = list.iterator(); it.hasNext(); ) {
				it.next().print();
			}
		}
	}

	public static class CDParameterNode {

		public final double x;

		public final double y;

		public final double param;

		public CDParameterNode(double xx, double yy, double pp) {
			x = xx;
			y = yy;
			param = pp;
		}

		public void print() {
			System.out.println(x + "\t" + y + "\t" + param);
		}
	}

	private static CDParameterList instance = null;

	private List<CDParameter> list;

	private CDParameterList() {
		list = new ArrayList<CDParameter>();
	}

	public static CDParameterList get() {
		if (instance == null)
			instance = new CDParameterList();
		return instance;
	}

	public boolean appendParameter(CDParameter cdp) {
//		cdp.print();
		return list.add(cdp);
	}

	public List<CDParameter> getList() {
		return Collections.unmodifiableList(list);
	}
}
